package com.shaoshaohuo.app.ui;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.JavascriptInterface;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.shaoshaohuo.app.R;

/**
 * Created by Administrator on 2017/8/18.
 */

public class WebTranslte extends AppCompatActivity {
    private WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.web_tanlste_layout);
        Intent intent = getIntent();
        String weburl = intent.getStringExtra("weburl");
        webView= (WebView) findViewById(R.id.web);
        webView.loadUrl(weburl);
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });
//        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setBuiltInZoomControls(false);
        webView.setBackgroundColor(Color.parseColor("#00ffffff"));
        webView.addJavascriptInterface(new Mytest(),"test");
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setLoadWithOverviewMode(true);

    }

    class Mytest{
        @JavascriptInterface
        public void finsh(){
            finish();
        }
    }
}
